package com.caiyouxi.boss.buser.controller;

import com.caiyouxi.boss.buser.model.SysRolesBean;
import com.caiyouxi.boss.buser.service.SysRolesService;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.control.BaseController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2017/10/26.
 */
@RestController
@RequestMapping("/boss/roles")
public class SysRolesController extends BaseController {

    private Logger logger = Logger.getLogger(SysRolesController.class);

    @Autowired
    private SysRolesService sysRolesService;



    //获取角色所有信息
    @RequestMapping("/get_list")
    public ResData get_roles_list(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){
        logger.info("获取所有的角色信息");
        return sysRolesService.get_all_roles(bean);
    }

    //添加角色信息
    @RequestMapping("/add_roles")
    public ResData add_roles(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){



        logger.info("添加角色信息");
        return sysRolesService.add_roles(bean);
    }

    //角色id获取角色信息
    @RequestMapping("/get_role_id")
    public ResData get_roles_by_id(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){
        logger.info("通过id获取角色信息");
        return sysRolesService.get_role_by_id(bean);
    }

    //修改角色信息
    @RequestMapping("/update_roles")
    public ResData update_roles(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){
        logger.info("修改角色信息");
        return sysRolesService.update_roles(bean);
    }


    //删除角色信息
    @RequestMapping("/delete_roles")
    public ResData delete_roles(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){
        logger.info("删除角色信息");
        return sysRolesService.delete_roles(bean);
    }

    //查出所有的权限
    @RequestMapping("/sys_all_rights")
    public ResData get_all_rights(HttpServletRequest request,HttpServletResponse response,@RequestBody SysRolesBean bean){
        logger.info("当前角色权限列表");
       return sysRolesService.get_all_rights(bean);

    }

    //查出角色权限信息
    @RequestMapping("/get_role_rights")
    public ResData get_role_rights(HttpServletRequest request,HttpServletResponse response,@RequestBody SysRolesBean bean){
        return sysRolesService.get_all_rights(bean);
    }

    //跟新用户信息
    @RequestMapping("/update_role_rights")
    public ResData update_role_rights(HttpServletRequest request,HttpServletResponse response,@RequestBody SysRolesBean bean){
        return sysRolesService.update_roles_rights(bean);
    }

    //通过角色id获取此角色的所有用户
    @RequestMapping("/get_user_role_id")
    public ResData get_user_role_id(HttpServletRequest request,HttpServletResponse response,@RequestBody SysRolesBean bean){
            return sysRolesService.get_user_role_id(bean);
    }

   //给用户添加新的角色
   @RequestMapping("/update_role_to_user")
   public ResData update_role_to_user(HttpServletRequest request, HttpServletResponse response, @RequestBody SysRolesBean bean){

       return sysRolesService.update_role_to_user(bean);
   }

}
